﻿using Learun.Util;
using SqlSugar;
using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace Learun.Application.Organization
{
    /// <summary>
    /// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
    /// Copyright (c) 2013-2018 Hexagon PPM
    /// 创建人：研发部
    /// 日 期：2017.03.04
    /// 描 述：角色管理
    /// </summary>
    [SugarTable(TableName = "LR_BASE_ROLE")]
    public class RoleEntity
    {
        #region 实体成员
        /// <summary>
        /// 角色主键
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_ROLEID", IsPrimaryKey = true)]
        public string F_RoleId { get; set; }
        /// <summary>
        /// 分类
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_CATEGORY")]
        public string F_Category { get; set; }
        /// <summary>
        /// 角色编码
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_ENCODE")]
        public string F_EnCode { get; set; }
        /// <summary>
        /// 角色名称
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_FULLNAME")]
        public string F_FullName { get; set; }
        /// <summary>
        /// 排序码
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_SORTCODE")]
        public int? F_SortCode { get; set; }
        /// <summary>
        /// 删除标记
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_DELETEMARK")]
        public int? F_DeleteMark { get; set; }
        /// <summary>
        /// 有效标志
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_ENABLEDMARK")]
        public int? F_EnabledMark { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_DESCRIPTION")]
        public string F_Description { get; set; }
        /// <summary>
        /// 创建日期
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_CREATEDATE")]
        public DateTime? F_CreateDate { get; set; }
        /// <summary>
        /// 创建用户主键
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_CREATEUSERID")]
        public string F_CreateUserId { get; set; }
        /// <summary>
        /// 创建用户
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_CREATEUSERNAME")]
        public string F_CreateUserName { get; set; }
        /// <summary>
        /// 修改日期
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_MODIFYDATE")]
        public DateTime? F_ModifyDate { get; set; }
        /// <summary>
        /// 修改用户主键
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_MODIFYUSERID")]
        public string F_ModifyUserId { get; set; }
        /// <summary>
        /// 修改用户
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "F_MODIFYUSERNAME")]
        public string F_ModifyUserName { get; set; }

        /// <summary>
        /// 项目ID
        /// </summary>
        /// <returns></returns>
        [SugarColumn(ColumnName = "PROJECTID")]
        public string ProjectId { get; set; }

        #endregion

        #region 扩展操作
        /// <summary>
        /// 新增调用
        /// </summary>
        public void Create()
        {
            UserInfo userInfo = LoginUserInfo.Get();
            this.F_CreateUserId = userInfo.userId;
            this.F_CreateUserName = userInfo.realName;

            this.F_RoleId = Guid.NewGuid().ToString();
            this.F_CreateDate = Time.MySqlTime;
            this.F_DeleteMark = 0;
            this.F_EnabledMark = 1;
            this.F_Category = "1";
        }
        /// <summary>
        /// 编辑调用
        /// </summary>
        /// <param name="keyValue">主键</param>
        public void Modify(string keyValue)
        {
            UserInfo userInfo = LoginUserInfo.Get();
            this.F_ModifyUserId = userInfo.userId;
            this.F_ModifyUserName = userInfo.realName;
            this.F_RoleId = keyValue;
            this.F_ModifyDate = Time.MySqlTime;
        }
        #endregion


        #region  扩展字段

        /// <summary>
        /// 专业   模型提资专业角色
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string Major { get; set; }

        /// <summary> 
        /// 角色成员（名称） 
        /// </summary> 
        /// <returns></returns> 
        [SugarColumn(IsIgnore = true)]
        public string MemberName { get; set; }
        #endregion
    }
}
